< previous page page_313 next page >

Page 313
        DBEngine.RepairDatabase strDBName
        MsgBox strDBName & " Repaired"
    End If
    '
End Sub
The code in Listing 9.3 declares a local variable for the database name and then prompts the user to enter the name of a database to repair. After checking to make sure a database name was entered, the code executes the RepairDatabase method and reports the results.
Save and run the program. When you click the Repair button, locate and select the DBREPAIR.MDB database (see Figure 9.3).
0313-01.jpg
Figure 9.3.
Entering a database to repair.
The repair method executes and the final message box appears.
warning.gif
The RepairDatabase method overwrites the existing file with the repaired database file. You should make a backup copy of your database files before you execute the RepairDatabase method.

Using the CompactDatabase Method
The CompactDatabase method cleans out empty space in Microsoft Jet databases and performs general optimization chores that improve access speed. You can also use the CompactDatabase method to convert older versions of Microsoft Jet databases to newer versions.
The syntax for this method is
DBEngine.CompactDatabase oldDatabase, NewDatabase, locale, options

 
< previous page page_313 next page >

If you like this book, buy it!